#!/bin/sh

#--------------------------------------------------------------------------------------------------------------------
# This is an example of how to create a web servable vlc tv flv type stream output: 
# Link example that the client will access will look like this: http://YOUR.IP.GOES.HERE:4555/stream.flv 
# 
# 1-- Verify permissions if needed on /dev/{your audio device} and /dev/{your video device}
# 2-- CLI was configured for specific hardware and is just an example, see these links: 
#        http://en.wikipedia.org/wiki/Video4Linux http://wiki.videolan.org/Main_Page
# 3-- Here are some requirements in Linux that are expected:
#        v4l / v4l2 (libv4l) for cable input access and cli frequency control
#        nmixer (mp3blaster) for presetting volume level  
#        cvlc (vlc-nox) for creating transcoded/muxed output http stream of tv input
# 4-- Configure server IP in cvlc string  (see end of cvlc configure statement and change 192.168.10.111)
# 5-- Execute prior to opening link to web interface
# 6-- pasuspender is used for suspending PulseAudio, you may not need that on your particular hardware.
# 7-- The port can be adjusted to anything, just update the index.php file with the new port also
# 8-- Preset the tuner frequency variable for v4l2-tuner-frequency=###### or just remove the setting.
#--------------------------------------------------------------------------------------------------------------------


# Force the audio settings via nmixer (unremark if volume needs to be configured prior to streaming video source):
# note: In my particular hardware configuration, I had to run a 1/8" phone plug cable from the audio output of 
# the tv card to the mic/line in of the soundcard to pick up the sound source of the tv card
#--------------------------------------------------------------------------------------------------------------------
#nmixer -s igain=50 mic=50 line=50 video=50 -q


# (cable coax) <--> (Bt878 video capture) <--> (v4l2 input) <--> (cvlc transcoding) <--> (flv http output):
#--------------------------------------------------------------------------------------------------------------------

# pasuspender -- cvlc v4l2:///dev/video0:width=320:height=240:fps=27 :v4l2-standard=3:v4l2-standard=45056 :v4l2-input=0 :input-slave=oss:// :v4l2-tuner-frequency=325250 -I dummy --sout '#transcode{vcodec=FLV1,acodec=mp3,ab=224,channels=1,samplerate=44100}:duplicate{dst=std{access=http,dst=192.168.10.111:4555/stream.flv}'
  pasuspender -- cvlc v4l2:///dev/video0:width=640:height=480:fps=30 :v4l2-standard=3:v4l2-standard=45056 :v4l2-input=0 :input-slave=oss:// :v4l2-tuner-frequency=325250 -I dummy --sout '#transcode{vcodec=FLV1,vb=1792,acodec=mp3,channels=1,samplerate=44100,ab=1792,width=320,height=240}:duplicate{dst=std{access=http,dst=192.168.10.111:4555/stream.flv}'
